//
//  XMDiscountListTableViewCell.m
//  XunMi
//
//  Created by MacBook on 2024/4/16.
//  Copyright © 2024 TieZhu. All rights reserved.
//

#import "XMDiscountListTableViewCell.h"
#import "XMDiscountsModel.h"

@interface XMDiscountListTableViewCell ()
@property (weak, nonatomic) IBOutlet UILabel *moneyLa;
@property (weak, nonatomic) IBOutlet UILabel *useableLa;
@property (weak, nonatomic) IBOutlet UIButton *selButton;
@property (weak, nonatomic) IBOutlet UILabel *dateLa;
@property (weak, nonatomic) IBOutlet UILabel *descLa;
@property (weak, nonatomic) IBOutlet UILabel *nameLa;
@property (weak, nonatomic) IBOutlet UILabel *typeLa;
@property (weak, nonatomic) IBOutlet UIImageView *bgImg1;
@property (weak, nonatomic) IBOutlet UIImageView *bgImg2;
@property (weak, nonatomic) IBOutlet UIImageView *leftImgV;

@end

@implementation XMDiscountListTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setModel:(XMDiscountsModel *)model {
    _model = model;
    self.selButton.selected = model.selected;
    self.nameLa.text = model.title;
    self.typeLa.text = model.type;
    self.leftImgV.image = kGetImage(model.leftImg);
    self.bgImg1.image = kGetImage(model.typeImg1);
    self.bgImg2.image = kGetImage(model.typeImg2);
    self.useableLa.text = kStringFormat(@"满%ld可使用", model.amount);
    self.descLa.text = model.describe;
    self.dateLa.text = kStringFormat(@"%@到期", model.expire_time);
    
    NSString *str = kStringFormat(@"%@%@", model.reduce, model.unitStr);
    NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:str];
    
    [attrStr addAttributes:@{NSFontAttributeName: kUIFontBold(26)} range:[str rangeOfString:model.reduce]];
    
    [attrStr addAttributes:@{NSFontAttributeName: kUIFontBold(12)} range:[str rangeOfString:model.unitStr]];
    
    self.moneyLa.attributedText = attrStr;

}

@end
